package cn.edu.lcvc.ebuy_23rj2.dao;

import cn.edu.lcvc.ebuy_23rj2.model.Admin;
import cn.edu.lcvc.ebuy_23rj2.model.query.AdminQuery;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface AdminDao {
    int countByUsernameAndPassword(@Param(value ="username") String username,@Param(value ="password" ) String password);

    Admin getByUsername(@Param(value ="username")String username);

    @Delete("delete from admin where id=#{username}")
    int deleteById(int id);
    int save (Admin admin);

    @Select("select count(1) as num from admin where username=#{username}")
    int countByUsername(String username);

    @Select("select * from admin where id=#{id}")
    Admin findById(int id);
    int update(Admin admin);

    @Select("select count(1) as num from admin where username=#{username} and id!=#{id}")
    boolean countByUsernameAndNotId(@Param(value = "username") String username,@Param(value = "id") Integer id);
    List<Admin> find(@Param(value = "query") AdminQuery adminQuery);
}
